

a1 = []
a2 = [4,5,6]
a3 = [*a1, *a2]

print(f"----a3:{a3}" )


adjust_picture_file_name_surffix = "_adjust"
img_name = "1213347_adjust.png"
index = img_name.find(adjust_picture_file_name_surffix)
print(f"----index:{index}" )


for i in range(7):
    print(f"----i:{i}")

print(f"#############################")
for i in range(6, 0, -1):
    print(f"----i:{i}")



aabb = b''
cc = int.from_bytes(aabb,'big')
print(f"------1111111-------cc:{aabb!= b''}")

import base64
o1 = "eyIxOTY2MTIiOiBbXSwgIjE5NjYxMSI6IFtdLCAiMTk2NjEwIjogW10sICIxOTY2MDkiOiBbXSwgIjEzMTA3MyI6IFtdfQ=="
o2 = "eyIxOTY2MTIiOiBbXSwgIjE5NjYxMSI6IFtdLCAiMTk2NjEwIjogW10sICIxOTY2MDkiOiBbXSwgIjEzMTA3MyI6IFtdLCAiMTMxMDc0IjogW119"
o3 = "eyIxOTY2MTIiOiBbXSwgIjE5NjYxMSI6IFtdLCAiMTk2NjEwIjogW10sICIxOTY2MDkiOiBbXSwgIjEzMTA3MyI6IFt7ImZsYXdfaWQiOiAiOTMiLCAicG9pbnRfbWF0cml4IjogbnVsbH0sIHsiZmxhd19pZCI6ICI5NCIsICJwb2ludF9tYXRyaXgiOiBudWxsfV0sICIxMzEwNzQiOiBbXX0="
o4 = "eyIxOTY2MTIiOiBbXSwgIjE5NjYxMSI6IFtdLCAiMTk2NjEwIjogW10sICIxOTY2MDkiOiBbXSwgIjEzMTA3MyI6IFtdLCAiMTMxMDc0IjogW3siZmxhd19pZCI6ICI5MCIsICJwb2ludF9tYXRyaXgiOiBudWxsfV19"
o5 = "eyIxOTY2MTIiOiBbXSwgIjE5NjYxMSI6IFtdLCAiMTk2NjEwIjogW10sICIxOTY2MDkiOiBbXSwgIjEzMTA3MyI6IFtdLCAiMTMxMDc0IjogW3siZmxhd19pZCI6ICI4OSIsICJwb2ludF9tYXRyaXgiOiBudWxsfV19"
o6 = "eyIxOTY2MTIiOiBbXSwgIjE5NjYxMSI6IFtdLCAiMTk2NjEwIjogW10sICIxOTY2MDkiOiBbXSwgIjEzMTA3MyI6IFt7ImZsYXdfaWQiOiAiOTMiLCAicG9pbnRfbWF0cml4IjogbnVsbH1dLCAiMTMxMDc0IjogW3siZmxhd19pZCI6ICI5MCIsICJwb2ludF9tYXRyaXgiOiBudWxsfV19"
o7 = "eyIxOTY2MTIiOiBbXSwgIjE5NjYxMSI6IFtdLCAiMTk2NjEwIjogW10sICIxOTY2MDkiOiBbXSwgIjEzMTA3MyI6IFtdLCAiMTMxMDc0IjogW3siZmxhd19pZCI6ICI4OSIsICJwb2ludF9tYXRyaXgiOiBudWxsfSwgeyJmbGF3X2lkIjogIjkwIiwgInBvaW50X21hdHJpeCI6IG51bGx9XX0="
o8 = "eyIxOTY2MTIiOiBbXSwgIjE5NjYxMSI6IFtdLCAiMTk2NjEwIjogW10sICIxOTY2MDkiOiBbXSwgIjEzMTA3MyI6IFt7ImZsYXdfaWQiOiAiOTMiLCAicG9pbnRfbWF0cml4IjogbnVsbH0sIHsiZmxhd19pZCI6ICI5NCIsICJwb2ludF9tYXRyaXgiOiBudWxsfV0sICIxMzEwNzQiOiBbeyJmbGF3X2lkIjogIjg5IiwgInBvaW50X21hdHJpeCI6IG51bGx9LCB7ImZsYXdfaWQiOiAiOTAiLCAicG9pbnRfbWF0cml4IjogbnVsbH1dfQ=="
o9 = "eyIxOTY2MTIiOiBbXSwgIjE5NjYxMSI6IFtdLCAiMTk2NjEwIjogW10sICIxOTY2MDkiOiBbXSwgIjEzMTA3MyI6IFt7ImZsYXdfaWQiOiAiOTMiLCAicG9pbnRfbWF0cml4IjogbnVsbH0sIHsiZmxhd19pZCI6ICI5NCIsICJwb2ludF9tYXRyaXgiOiBudWxsfV0sICIxMzEwNzQiOiBbeyJmbGF3X2lkIjogIjkwIiwgInBvaW50X21hdHJpeCI6IG51bGx9XX0="
content1 = base64.b64decode(o1).decode('utf-8')
content2 = base64.b64decode(o2).decode('utf-8')
content3 = base64.b64decode(o3).decode('utf-8')
content4 = base64.b64decode(o4).decode('utf-8')
content5 = base64.b64decode(o5).decode('utf-8')
content6 = base64.b64decode(o6).decode('utf-8')
content7 = base64.b64decode(o7).decode('utf-8')
content8 = base64.b64decode(o8).decode('utf-8')
content9 = base64.b64decode(o9).decode('utf-8')

print(f"-------------content:{ content1 }")
print(f"-------------content:{ content2 }")
print(f"-------------content:{ content3 }")
print(f"-------------content:{ content4 }")
print(f"-------------content:{ content5 }")
print(f"-------------content:{ content6 }")
print(f"-------------content:{ content7 }")
print(f"-------------content:{ content8 }")
print(f"-------------content:{ content9 }")


from typing import Union
aaaaa:Union[int,str] = ""

aaaaa = "333333"
print(f"-------aaaaa: {aaaaa} , {type(aaaaa)}")
aaaaa = 4444444
print(f"-------aaaaa: {aaaaa} , {type(aaaaa)}")


import json
data = dict()
data["pic_id"] = 10000
data["isMain"] = 1
data["neck_id"] = 10000
data["left_id"] = 10001
data["right_id"] = 10002
bytes_data = json.dumps(data).encode('utf-8')


print(f"-------data: {bytes_data} , {type(bytes_data)}")
img_data_str = bytes_data.decode("utf-8")
print(f"-----图片信息---img_data_str:", img_data_str)
img_data = eval(img_data_str)
print(f"-----图片信息---img_data:" , img_data , f"-----type:{type(img_data)}")


import asyncio
from typing import Optional

wait_picture_file_path_queue: Optional[asyncio.Queue[dict]] = asyncio.Queue()

async def loop():
    while True:
        if wait_picture_file_path_queue.qsize() > 0:
            item = wait_picture_file_path_queue.get_nowait()
            print(f"-------111111-----item: {item}")
        extra = dict(key="AAAAA")
        item = dict(time_in_mills=1000 , path="xxxxxxxx", extra= extra)
        await wait_picture_file_path_queue.put(item)
        print(f"---wait_picture_file_path_queue: {wait_picture_file_path_queue.qsize()}")
        await asyncio.sleep(1)


async def test():
    tasks = [asyncio.create_task(loop())]
    try:
        await asyncio.gather(*tasks)
    except Exception as e:
        for task in tasks:
            task.cancel("error")



for i in range(-2,7):
    print(f"-----i: {i}")




from datetime import datetime
origin_date_str = "2024-01"
origin_date = datetime.strptime(origin_date_str, "%Y-%m")
origin_date_1 = origin_date.strftime("%Y_%m")
print(f"-------origin_date_1:{origin_date_1}")
year = origin_date.year
month = origin_date.month
print(f"-------date:{year}-{month}")









ori = b'0000'
length = int.from_bytes(ori , 'big', signed=False)
print(f"-------length:{length}")



arr = "aaa".split(",")
print(f"-------arr:{arr}")



print(f"-----2222222------list: {[9]} , type: {type([9])}")

print(f"-------timestamp: {datetime.now().timestamp()}")







ll = ['1','2','3','4','5']
print(f"{','.join(ll)}")


all_dict = {"1":"100","2":"200","3":"300","4":"400"}
copied_dict = all_dict.copy()
print(f"----------all_dict: " , all_dict)
print(f"----------copied_dict: " , copied_dict)
print(f"----------id all_dict: " , id(all_dict))
print(f"----------id copied_dict: " , id(copied_dict))


import random

# 假设我们有一个列表
my_list = [1, 2, 3, 4, 5, 6,]

# 我们想随机挑选出 3 个元素
sample_size = 6

# 使用 random.sample 从列表中随机挑选出 3 个元素
random_sample = random.sample(my_list, sample_size)

print(random_sample)



from enum import Enum

class ProLineComponentState(Enum):
    """ 产线运行状态 """
    STOP_URGENT = dict(code = 0, memo = "急停中")
    MANUAL_MODE = dict(code = 1, memo = "手动模式")
    PAUSE = dict(code = 2 , memo = "暂停中")
    WAIT_INIT = dict(code = 3, memo = "等待初始化")
    INITIALIZING = dict(code = 4 , memo = "初始化中")
    WAIT_RUNNING = dict(code = 5, memo = "等待启动")
    RUNNING = dict(code=6, memo="运行中")


def find_component_state_by_name(state_name):
    states = [member.value for member in ProLineComponentState]
    map_as_dict = {}
    for state in states:
        map_as_dict[state["memo"]] = state["code"]
    if state_name in map_as_dict.keys():
        return map_as_dict[state_name]
    else:
        return None

print(f"------state: {find_component_state_by_name('等待初始')}")

products = [None for _ in range(14)]
print(f"-------len products: {len(products)}")

for i in range(14 - 1, -1, -1):
    print(f"-------i: {i}")










